#!/usr/bin/env python3
# --*-- coding:UTF8 --*--

# date: 2018-01-10

import random

# 读取成绩
with open('score.txt','r') as f:
    score = f.readline().split()

# 游戏次数,最小轮数,总共多少轮
game_times,min_times,total_times = int(score[0]), int(score[1]), int(score[2])

# 平均局数
if game_times > 0 :
    avg_times = float(total_times) / game_times
    print('你已经玩了%d次, 最少%d轮猜出, 平均%.2f轮猜出答案' % (game_times, min_times, avg_times))
else:
    avg_times = 0
    print('你还没有玩过游戏!')

#游戏开始
num = random.randint(1,10)
times = 0  # 记录本次游戏轮数
print("请猜测一个10以内的整数? ")
bingo = False
while bingo == False:
    times += 1
    answer = int(input())
    if answer < num:
        print("It's small")
    if answer > num:
        print("It's big")
    if answer == num:
        print('Bingo')
        bingo = True

# 记录游戏数据
if game_times == 0 or times < min_times:
    min_times = times

total_times = total_times + times

game_times += 1

#result = "%d + %d + %d" % (game_times, min_times, total_times))
result = str(game_times) + " " +str(min_times) + " " + str(total_times)

with open('score.txt','w') as f:
    f.write(result)

let's go
